import { createTimeColumn, isDisabledColumn } from '@/common/table-columns';
import { BaseColumnType } from '@/components/common-table/common-table-type';
import { Role } from './auth.type';

const companyNameColumn: BaseColumnType = {
  name: 'base-column',
  prop: 'companyName',
  label: '企业名称',
  width: 120,
  align: 'center',
};

const companyCodeColumn: BaseColumnType = {
  name: 'base-column',
  prop: 'companyCode',
  label: '标识码',
  width: 120,
  align: 'center',
};

const companyLegalColumn: BaseColumnType = {
  name: 'base-column',
  prop: 'legal',
  label: '企业法人',
  width: 120,
  align: 'center',
};

const companyLegalPhoneColumn: BaseColumnType = {
  name: 'base-column',
  prop: 'legalPhone',
  label: '法人联系方式',
  width: 120,
  align: 'center',
};

const companyLegalEmailColumn: BaseColumnType = {
  name: 'base-column',
  prop: 'legalEmail',
  label: '企业邮箱',
  width: 120,
  align: 'center',
};

const companyAddressColumn: BaseColumnType = {
  name: 'base-column',
  prop: 'address',
  label: '企业地址',
  align: 'center',
  minWidth: 120,
};

const companyAdminNumberColumn: BaseColumnType = {
  name: 'base-column',
  prop: 'adminNumber',
  label: '账号数量',
  width: 120,
  align: 'center',
};

const adminCompanyNameColumn: BaseColumnType = {
  name: 'base-column',
  prop: 'companyName',
  label: '所属公司',
  minWidth: 120,
  align: 'center',
};

const adminUsernameColumn: BaseColumnType = {
  name: 'base-column',
  prop: 'username',
  label: '用户名',
  width: 120,
  align: 'center',
};

const adminRoleColumn: BaseColumnType = {
  name: 'base-column',
  prop: 'role',
  label: '角色',
  width: 120,
  align: 'center',
  formatter: (row) => {
    return Role[row.role];
  },
};

const adminRealnameColumn: BaseColumnType = {
  name: 'base-column',
  prop: 'realname',
  label: '姓名',
  width: 80,
  align: 'center',
};

const adminSexColumn: BaseColumnType = {
  name: 'base-column',
  prop: 'sex',
  label: '性别',
  width: 60,
  align: 'center',
  formatter: (row) => (row.sex == 1 ? '男' : '女'),
};
const adminPhoneColumn: BaseColumnType = {
  name: 'base-column',
  prop: 'phone',
  label: '手机号',
  width: 120,
  align: 'center',
};

const adminEmailColumn: BaseColumnType = {
  name: 'base-column',
  prop: 'email',
  label: '邮箱',
  width: 200,
  align: 'center',
};
const adminBirthColumn: BaseColumnType = {
  name: 'base-column',
  prop: 'birth',
  label: '生日',
  width: 120,
  align: 'center',
};

const userNameColumn: BaseColumnType = {
  name: 'base-column',
  prop: 'username',
  label: '用户名',
  width: 120,
  align: 'center',
};

// role
const roleNameColumn: BaseColumnType = {
  name: 'base-column',
  prop: 'roleName',
  label: '角色名称',
  width: 120,
  align: 'center',
};
const roleAuthoritiesColumn: BaseColumnType = {
  name: 'base-column',
  prop: 'roleName',
  label: '权限',
  align: 'center',
};

export const companyTableColumns = [
  companyNameColumn,
  companyCodeColumn,
  companyLegalColumn,
  companyLegalPhoneColumn,
  companyLegalEmailColumn,
  companyAddressColumn,
  companyAdminNumberColumn,
  createTimeColumn,
  isDisabledColumn,
];

export const adminTableColumns = [
  adminCompanyNameColumn,
  adminUsernameColumn,
  adminRoleColumn,
  adminRealnameColumn,
  adminSexColumn,
  adminPhoneColumn,
  adminEmailColumn,
  adminBirthColumn,
  createTimeColumn,
  isDisabledColumn,
];

export const userTableColumns = [
  companyNameColumn,
  userNameColumn,
  adminUsernameColumn,
  adminPhoneColumn,
  adminSexColumn,
  adminEmailColumn,
  adminBirthColumn,
  createTimeColumn,
  isDisabledColumn,
];

export const rolwTableColumns = [roleNameColumn, roleAuthoritiesColumn];
